<script src="js/jquery-1.9.1.min.js"></script>

<?php
require_once './classInfo.php';
$info = new info();
$working = $info->working();
date_default_timezone_set("Asia/Saigon");
?>
<style>
    .yellow { background: yellow;}
    .green { background: green;}
    .red { background: red;display: block;  -moz-animation: fadein 3s; /* Firefox */
           -webkit-animation: fadein 3s; /* Safari and Chrome */
           -o-animation: fadein 3s; /* Opera */ }
    @keyframes fadein {
        from {
        opacity:0;
    }
    to {
        opacity:1;
    }
    }
    @-moz-keyframes fadein { /* Firefox */
        from {
        opacity:0;
    }
    to {
        opacity:1;
    }
    }
    @-webkit-keyframes fadein { /* Safari and Chrome */
        from {
        opacity:0;
    }
    to {
        opacity:1;
    }
    }
    @-o-keyframes fadein { /* Opera */
        from {
        opacity:0;
    }
    to {
        opacity: 1;
    }
    }
</style>
<?php
function cssTime($datefrom,$dateto,$datecurent)
{
   $css="";
   if(strtotime($datefrom) < strtotime($datecurent) && strtotime($datecurent) < strtotime($dateto)) $css = "class=yellow";
   else if(strtotime($datefrom)>strtotime($datecurent)) 
   {
       if(strtotime($datefrom)-strtotime($datecurent)<3600) $css = "class=red";
   }
   else if(strtotime($dateto) < strtotime($datecurent))  $css = "class=green";
   return $css;
}
?>
<table>
    <?php while ($row = mysql_fetch_assoc($working)) { ?>
        <tr>
            <td <?php echo cssTime($row['checkout'], $row['checkin'], date('Y-m-d H:i:s')) ?>><?php echo $row['content'] ?></td>
            <td><?php echo $row['checkout'] ?></td>
            <td><?php echo date('Y-m-d H:i:s') ?></td>
            <td><?php echo strtotime($row['checkout']) - strtotime(date('Y-m-d H:i:s')) ?></td>
        </tr>
    <?php } ?>
</table>


